home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / CONTRIB / ASPI.ZIP / aspitest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-25  |  1.3 KB  |  65 lines

  1. #include <stdio.h>
  2. #include "aspi.h"
  3. #include "scsidefs.h"
  4.  
  5. static char *astatus[] = { "Play", "Pause", "Ready", "Stop" };
  6.  
  7. main()
  8. {
  9.   int t, h, l, id, nh;
  10.   nh = aspi_init();
  11.   if (nh < 1)
  12.     return 1;
  13.   for (h=0; h<nh; h++)
  14.     for (t=0; t<8; t++)
  15.       for (l=0; l<8; l++)
  16.       {
  17.     int type;
  18.     id = ASPI_MKID(h,t,l);
  19.     type = aspi_device_type(id);
  20.     if (type != -1)
  21.     {
  22.       unsigned char cdb[12];
  23.       char buf[96];
  24.       printf("scsi(%d,%d,%d) = 0x%02x",
  25.          ASPI_ID2HOSTAD(id),
  26.          ASPI_ID2TARGET(id),
  27.          ASPI_ID2LUN(id),
  28.          type);
  29.  
  30.       cdb[0] = 0x12;
  31.       cdb[1] = l << 5;
  32.       cdb[2] = 0x00;
  33.       cdb[3] = 0x00;
  34.       cdb[4] = 96;
  35.       cdb[5] = 0x00;
  36.       aspi_exec(id, buf, 96, ASPI_RW_READ, cdb, 6);
  37.       printf(" - %.8s %.16s %.4s %.8s %.12s\n",
  38.          buf+8, buf+16, buf+32, buf+36, buf+44);
  39.  
  40.       if (type == DTYPE_CROM)
  41.       {
  42.         int old_t = -1;
  43.         while (!kbhit())
  44.         {
  45.           memset(cdb, 0, 10);
  46.           cdb[0] = 0xc6;
  47.           cdb[1] = 10 | (l<<5);
  48.           aspi_exec(id, buf, 10, ASPI_RW_READ, cdb, 10);
  49.           if (buf[6] != old_t)
  50.         printf("  %02x  %02x:%02x:%02x  %02x:%02x:%02x  %s\r",
  51.                buf[2], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], astatus[buf[0]]);
  52.           old_t = buf[6];
  53.           fflush(stdout);
  54.           if (buf[0])
  55.         break;
  56.         }
  57.         if (kbhit())
  58.           getkey();
  59.       }
  60.     }
  61.       }
  62.   aspi_close();
  63.   return 0;
  64. }
  65.